package com.report.utils;

import java.io.File;
import java.io.IOException;

import javax.servlet.http.HttpServletRequest;

import com.oreilly.servlet.MultipartRequest;


public class UploadFile {
	public void uploadFile(HttpServletRequest req) throws IOException{
		int maxSize = 5*1024*1024; //5MB
		MultipartRequest multi = new MultipartRequest(req, ".", maxSize);
		File photo = multi.getFile("fileName");
		String dir = req.getRealPath("upload");
		if(photo != null){	
			String fileName = multi.getFilesystemName("fileName");
			photo.renameTo(new File(dir, fileName));
		}
	}

}
